import React, { useEffect, useState } from 'react'

const root_path = 'http://localhost:3000/#/'

const OtherPages = (props: any) => {
  const [iFrameHeight, setIFrameHeight] = useState('0px')
  const [url, setUrl] = useState('')
  useEffect(() => {
    let path = props.match.params.path //路由参数
    let url = root_path + path
    setUrl(url)
    console.log(path, url)
  }, [props.match.params.path])
  return (
    <div>
      <iframe
        title={'other'}
        scrolling='yes'
        frameBorder='0'
        style={{
          width: '100%',
          height: iFrameHeight,
          overflow: 'visible',
        }}
        onLoad={() => {
          //iframe高度不超过content的高度即可
          let h = document.documentElement.clientHeight
          setIFrameHeight(h + 'px')
        }}
        src={url}
      />
    </div>
  )
}

export default OtherPages
